package com.stadium.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.stadium.common.utils.SqlMapper;
import com.stadium.common.utils.UserUtils;
import com.stadium.dto.RUserCategoryAreaDto;
import com.stadium.entity.RUserCategoryArea;
import com.stadium.mapper.RUserCategoryAreaMP;
import com.stadium.service.RUserCategoryAreaSV;
import com.stadium.vo.RUserCategoryAreaVo;
import com.stadium.vo.searchVo.RUserCategoryAreaSearchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class RUserCategoryAreaSVI implements RUserCategoryAreaSV {
    @Autowired
    private RUserCategoryAreaMP mapper;
    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<RUserCategoryArea> queryBySQL(String sql, Map<String, Object> map) {
        return sqlMapper.selectList(sql, map, RUserCategoryArea. class);
    }

    @Override
    public void save(RUserCategoryAreaVo rUserCategoryAreaVo) {
        RUserCategoryArea rUserCategoryArea =new  RUserCategoryArea();
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        BeanUtils.copyProperties(rUserCategoryAreaVo,rUserCategoryArea);
        rUserCategoryArea.setId(id);
        mapper.save(rUserCategoryArea);
    }

    @Override
    public void update(RUserCategoryAreaVo rUserCategoryAreaVo) {
        RUserCategoryArea rUserCategoryArea =new  RUserCategoryArea();
        BeanUtils.copyProperties(rUserCategoryAreaVo,rUserCategoryArea);
        rUserCategoryArea.setUpdateUser(UserUtils.getUserId());
        mapper.update(rUserCategoryArea);
    }

    @Override
    public void saveBatch(List<RUserCategoryArea> list) {
        mapper.saveBatch(list);
    }

    @Override
    public void delete(String id) {
        mapper.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        mapper.deleteBatch(ids);
    }


    @Override
    public List<RUserCategoryAreaDto> query(RUserCategoryAreaSearchVo searchVo) {
        return mapper.query(searchVo);
    }

    @Override
    public RUserCategoryAreaDto get(String id) {
        return mapper.get(id);
    }

    @Override
    public int getCount(RUserCategoryAreaSearchVo searchVo) {
        return mapper.getCount(searchVo);
    }

    @Override
    public List<RUserCategoryAreaDto> getByUserId(String userId) {
        return mapper.getByUserId(userId);
    }

}
